<h2>Listing Users</h2>

<table cellspacing = "10">
  <tr>
    <th><%= 'User' %></th>
    <th><%= 'Community' %></th>
    <th><%= 'Role' %></th>
  </tr>

  <% for user in @users %>
    <tr>
      <td><%=h user.name %></td>
      <% @communityname = Community.find( user.community_id ) %>
      <td><%=h @communityname.name %></td>
      <td><%=h user.role %></td>

      <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
      <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
  </tr>
<% end %>
</table>

<%= link_to 'Previous page', { :page => @user_pages.current.previous } if @user_pages.current.previous %>
<%= link_to 'Next page', { :page => @user_pages.current.next } if @user_pages.current.next %>

<br />

<%= link_to 'New user', :action => 'new' %>
